package b.cif.impl

import b.cif.api.T客户Service
import b.utils.api.T底层Service
import b.utils.entity.C流水号PersistentEntity
import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.JsonSerializerRegistry
import com.lightbend.lagom.scaladsl.server.{LagomApplication, LagomApplicationContext, LagomApplicationLoader, LagomServer}
import com.softwaremill.macwire.wire
import play.api.libs.ws.ahc.AhcWSComponents

abstract class C客户Application(context: LagomApplicationContext) extends LagomApplication(context)
  with AhcWSComponents
  with CassandraPersistenceComponents {

  override lazy val lagomServer: LagomServer = LagomServer.forServices(
    bindService[T客户Service].to(wire[C客户ServiceImpl])
  )

  persistentEntityRegistry.register(wire[C客户PersistentEntity])
  persistentEntityRegistry.register(wire[C客户号PersistentEntity])
  persistentEntityRegistry.register(wire[C流水号PersistentEntity])

  readSide.register(wire[C客户ReadSide])

  lazy val v客户Service: T客户Service = serviceClient.implement[T客户Service]
  lazy val v底层Service: T底层Service = serviceClient.implement[T底层Service]

  override lazy val jsonSerializerRegistry: JsonSerializerRegistry = wire[C客户SerializerRegistry]

}

class C客户ApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new C客户Application(context) with LagomDevModeComponents

  override def load(context: LagomApplicationContext): LagomApplication = new C客户Application(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
  }
}
